package com.jiaai.cloud.base.page;

import com.baomidou.mybatisplus.plugins.Page;
import org.apache.commons.lang3.StringUtils;

public class FrontPage<T> {


    //每页显示条数
    private int pageSize = 10;

    //当前页数
    private int page = 1;

    //排序的字段
    private String sidx;

    //排序方式 asc升序  desc降序
    private String sord;


    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public String getSidx() {
        return sidx;
    }

    public void setSidx(String sidx) {
        this.sidx = sidx;
    }

    public String getSord() {
        return sord;
    }

    public void setSord(String sord) {
        this.sord = sord;
    }

    //获取mybatisPlus封装的Page对象
    public Page<T> getPagePlus(){
        Page<T> pagePlus = new Page<T>();
        pagePlus.setCurrent(this.page);
        pagePlus.setSize(this.pageSize);
        if(!StringUtils.isEmpty(this.sord)&&this.sord.toUpperCase().indexOf("ASC")>=0){
            pagePlus.setAsc(true);
        }
        pagePlus.setOrderByField(this.sidx);
        return pagePlus;
    }
}